{if $smarty.get.print != 1}
  {include file="header.tpl"}
{else}
  {include file="headerPrint.tpl"}
{/if}
<script type="text/javascript">
function bookFunction(id)
{
  document.form1.bdate.value="1";
  document.form1.submit();
}
function myFunction()
{
	if(confirm("Are You Sure To Delete")== true)
	{
		return true;
	}
	else
	{
		return false;
	}
}
</script>
<form name="form1" action="" method="post">
<input type="hidden" name="bdate" id="bdate" value="0" />
<center><h4>{$l_kaarigarDetail}</h4></center>
<div class="contentDiv">
  <table border="0" align="center" width="100%" cellspacing="0" cellpadding="4">
    <tr><hr COLOR="#000000" /></tr>  
		 <tr>
		  <td colspan="4" class="table1">
		    {$l_kaarigarName} :
		    <select name="kaarigarId" onchange="bookFunction()" autofocus />
		      <option value="0">{$l_kaarigarName}</option>
		      {html_options values=$kaarigar.id output=$kaarigar.name selected={$kaarigarId}}
		    </select>
		  </td>
		  <td colspan="5" class="table1">
		    {$l_from} : 
		      {html_select_date prefix="fromDate" start_year="-2" end_year="+1" field_order="DMY" day_value_format="%02d" time={$kaarigarFromDate}}
		    {$l_to} 
  		    {html_select_date prefix="toDate" start_year="-2" end_year="+1" field_order="DMY" day_value_format="%02d" time={$toDate}}
		  </td>
		  <td class="table1"><input type="submit" name="submitBtn" value="{$l_find}" /></td>
		   {if $smarty.get.print != 1}
		  <td class="table1"><a href="kaarigarDetail.php?print=1&fromDate={$fromDate}&toDate={$toDate}&kaarigarId={$kaarigarId}">Print</a></td>
		    {else}
    {/if}
		</tr>
	</table>	
	<table border="1" align="center" width="100%" cellspacing="0" cellpadding="1">
    <tr><hr COLOR="#000000" /></tr> 
		<tr class="table1">
		  <th width="7%">&nbsp;</th>
		  <th width="8%">Date :</th>
		  <th width="9%">Parti</th>
		  <th align="right">{$l_debit}</th>
		  <th align="right">{$l_credit}</th>
		  <th width="9%">Parti</th>
		  <th align="right">{$l_vadhaaroGhataado}</th>
		  <th align="right" width="9%">Ad Javak</th>
		  <th align="right" width="9%">Ad Aavak</th>
		  <th align="right">{$l_qty}</th>
		  <th align="right">{$l_rate}</th>
		  <th align="right">{$l_crAmount}</th>
		  <th align="right">{$l_drAmount}</th>
		  <th align="right">{$l_crDr}</th>
		</tr>
		<tr class="table2">
		  <td>&nbsp;</td>
		  <td>&nbsp;</td>
		  <td align="right" style="border-right:1px;"><b>{$opening.particulars}</b></td>
		  <td align="right" style="border-right:1px;">{if $opening.debit != 0}{$opening.debit|string_format:"%.0f"}{/if}</td>
		  <td align="right" style="border-right:1px;">{if $opening.credit != 0}{$opening.credit|string_format:"%.0f"}{/if}</td>
		  <td align="right" style="border-right:1px;">{$opening.particular}</td>
		  <td align="right" style="border-right:1px;">{if $opening.vadhaaroGhatado != 0}{$opening.vadhaaroGhatado|string_format:"%.0f"}{/if}</td>
		  <td align="right" style="border-right:1px;">{if $opening.addDebit != 0}{$opening.addDebit|string_format:"%.0f"}{/if}</td>
		  <td align="right" style="border-right:1px;">{if $opening.addCredit != 0}{$opening.addCredit|string_format:"%.0f"}{/if}</td>
		  <td align="right" style="border-right:1px;">{if $opening.qty != 0}{$opening.qty|string_format:"%.0f"}{/if}</td>
		  <td align="right" style="border-right:1px;">{if $opening.rate != 0}{$opening.rate|string_format:"%.0f"}{/if}</td>
		  <td align="right" style="border-right:1px;">{if $opening.crAmount != 0}{$opening.crAmount|string_format:"%.0f"}{/if}</td>
		  <td align="right" style="border-right:1px;">{if $opening.drAmount != 0}{$opening.drAmount|string_format:"%.0f"}{/if}</td>
		  <td align="right" style="border-right:1px;">{if $opening.totalAmt}{$opening.totalAmt|string_format:"%.0f"}{/if}</td>
		</tr>
		{section name="sec" loop=$kaarigarDetail|@count}
		<tr class="table2">
			<td>
		    {if $smarty.get.print != 1}
		      {if $kaarigarDetail[sec].kaarigarMasterId != $kaarigarDetail[$smarty.section.sec.index-1].kaarigarMasterId}<a href="kaarigarDetailList.php?print=1&kaarigarMasterId={$kaarigarDetail[sec].kaarigarMasterId}&kaarigarId={$kaarigarDetail[sec].kaarigarId}&kaarigarDate={$kaarigarDetail[sec].kaarigarMasterDate}">Print</a>{else}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{/if}
		      {if $kaarigarDetail[sec].kaarigarMasterId != $kaarigarDetail[$smarty.section.sec.index-1].kaarigarMasterId}<a href="kaarigarDetailDelete.php?kaarigarMasterId={$kaarigarDetail[sec].kaarigarMasterId}" onClick="return(confirm('Warning: Are you sure?');"><img src="./images/b_drop.png" border="0" width="15" height="15"></a>{else}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{/if}
		      {if $kaarigarDetail[sec].kaarigarMasterId != $kaarigarDetail[$smarty.section.sec.index-1].kaarigarMasterId}<a href="kaarigarEntry.php?kaarigarMasterId={$kaarigarDetail[sec].kaarigarMasterId}"><img src="./images/b_edit.png" border="0" width="15" height="15"></a>{else}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{/if}
		    {else}
		      &nbsp;
		    {/if}
		  </td>
		  <td align="right" style="border-right:1px;" NOWRAP>{$kaarigarDetail[sec].kaarigarMasterDate|date_format:"%d-%m-%Y"}</td>
		  <td NOWRAP>{$kaarigarDetail[sec].kaarigarDate|date_format:"%d-%m-%Y"}&nbsp;&nbsp;{$kaarigarDetail[sec].particulars}</td>
		  <td align="right" style="border-right:1px; color:green;">{if $kaarigarDetail[sec].debit != 0}{$kaarigarDetail[sec].debit|string_format:"%.0f"}{else}&nbsp;{/if}</td>
		  <td align="right" style="border-right:1px; color:red;">{if $kaarigarDetail[sec].credit != 0}{$kaarigarDetail[sec].credit|string_format:"%.0f"}{else}&nbsp;{/if}</td>
		  <td align="left" style="border-right:1px;">{$kaarigarDetail[sec].particular}</td>
		  {if $kaarigarDetail[sec].addedvadhaaroGhatado > 0}
		    <td align="right" style="border-right:1px; color:red;">{if $kaarigarDetail[sec].kaarigarMasterId != $kaarigarDetail[$smarty.section.sec.index-1].kaarigarMasterId}{$kaarigarDetail[sec].addedvadhaaroGhatado|string_format:"%.0f"}{else}&nbsp;{/if}</td>
		  {else}
		    <td align="right" style="border-right:1px; color:green;">{if $kaarigarDetail[sec].kaarigarMasterId != $kaarigarDetail[$smarty.section.sec.index-1].kaarigarMasterId}{$kaarigarDetail[sec].addedvadhaaroGhatado|string_format:"%.0f"}{else}&nbsp;{/if}</td>
		  {/if}
		  <td align="right" style="border-right:1px; color:green;">{if $kaarigarDetail[sec].addDebit != 0}{$kaarigarDetail[sec].addDebit|string_format:"%.0f"}{else}&nbsp;{/if}</td>
		  <td align="right" style="border-right:1px; color:red;">{if $kaarigarDetail[sec].addCredit != 0}{$kaarigarDetail[sec].addCredit|string_format:"%.0f"}{else}&nbsp;{/if}</td>
		  <td align="right" style="border-right:1px;">{if $kaarigarDetail[sec].qty != 0}{$kaarigarDetail[sec].qty|string_format:"%.0f"}{else}&nbsp;{/if}</td>
		  <td align="right" style="border-right:1px;">{if $kaarigarDetail[sec].rate != 0}{$kaarigarDetail[sec].rate}{else}&nbsp;{/if}</td>
		  <td align="right" style="border-right:1px; color:red;">{if $kaarigarDetail[sec].crAmount != 0}{$kaarigarDetail[sec].crAmount|string_format:"%.0f"}{else}&nbsp;{/if}</td>
		  <td align="right" style="border-right:1px; color:green;">{if $kaarigarDetail[sec].drAmount != 0}{$kaarigarDetail[sec].drAmount|string_format:"%.0f"}{else}&nbsp;{/if}</td>
		  {if $kaarigarDetail[sec].totalAmt > 0}
		    <td align="right" style="border-right:1px; color:green;">{if $kaarigarDetail[sec].totalAmt != 0}{$kaarigarDetail[sec].totalAmt|string_format:"%.0f"}{/if}</td>
		  {else}
		    <td align="right" style="border-right:1px; color:red;">{if $kaarigarDetail[sec].totalAmt != 0}{$kaarigarDetail[sec].totalAmt|string_format:"%.0f"}{/if}</td>
		  {/if}
		</tr>
		{/section}
    <tr><td colspan="14"><hr COLOR="#000000" /></td></tr> 
		<tr class="table1">
		  <td>
      {if $smarty.get.print != 1}
        <th>&nbsp;</th>
        <th>&nbsp;</th>
		    <th colspan="2" align="right">{$l_total}</th>
		    <th>&nbsp;</th>
		    {if $total.vadhGhat > 0}
		      <th align="right" style="color:red;">{$total.vadhGhat|string_format:"%.2f"}</th>
		    {else}
		      <th align="right" style="color:green;">{$total.vadhGhat|string_format:"%.2f"}</th>
		    {/if}
		    <th>Ad VadhGhat:</th>
		    <th align="right" style="color:red;">{$total.addVadhGhat|string_format:"%.0f"}</th>
		    <th align="right">{$total.qty|string_format:"%.0f"}</th>
		    <th>&nbsp;</th>
		    <th align="right" style="color:red;">{$total.crAmount|string_format:"%.0f"}</th>
		    <th align="right" style="color:green;">{$total.drAmount|string_format:"%.0f"}</th>
		    {if $total.totalAmt >0}
		    <th align="right" style="color:green;">{$total.totalAmt|string_format:"%.0f"}</th>
		    {else}
		    <th align="right" style="color:red;">{$total.totalAmt|string_format:"%.0f"}</th>
		    {/if}
	    {else}
		    <th colspan="4" align="right">{$l_total}</th>
		    <th>&nbsp;</th>
		    <th align="right" style="color:red;">{$total.vadhGhat|string_format:"%.2f"}</th>
		    <th>&nbsp;</th>
		    <th align="right" style="color:red;">{$total.addVadhGhat|string_format:"%.0f"}</th>
		    <th align="right">{$total.qty|string_format:"%.0f"}</th>
		    <th>&nbsp;</th>
		    <th align="right" style="color:green;">{$total.crAmount|string_format:"%.0f"}</th>
		    <th align="right" style="color:green;">{$total.drAmount|string_format:"%.0f"}</th>
		    <th align="right" >{$total.totalAmt|string_format:"%.0f"}</th>
		  {/if}
		  </td>
		</tr>
  </table>
</div>
</form>
{if $smarty.get.print != 1}
  {include file="footer.tpl"}
{/if}
